package com.manjiwang.middleground.service.impl;

import com.manjiwang.middleground.feign.GoodsFeignService;
import com.manjiwang.middleground.feign.OrderFeignService;
import com.manjiwang.middleground.service.MiddlegroundService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 数据中台服务层接口实现
 *
 * @Author Yang Hai Feng
 * @Date 2021/8/10 21:43
 */
@Service
public class MiddlegroundServiceImpl implements MiddlegroundService {

    @Autowired
    private GoodsFeignService goodsFeignService;

    @Autowired
    private OrderFeignService orderFeignService;

    @GlobalTransactional
    @Override
    public Boolean placeOrderBy(String goodsId) {
        // 扣减商品库存
        goodsFeignService.updateGoods(goodsId);
        // 创建订单
        orderFeignService.updateOrder(goodsId);
        return true;
    }
}
